
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Anime| Log in</title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <!-- Bootstrap 3.3.4 -->
    <link href="<?php echo base_url('assets');?>/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <!-- Font Awesome Icons -->
    <link href="<?php echo base_url('assets');?>/lib/animate/css/animate.min.css" rel="stylesheet" type="text/css" />
    <!--Animte css-->
    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <!-- Theme style -->
    <link href="<?php echo base_url('assets');?>/admin/css/AdminLTE.min.css" rel="stylesheet" type="text/css" />
    <link href="<?php echo base_url('assets');?>/admin/css/custom.css" rel="stylesheet" type="text/css" />
    <!-- iCheck -->
    <link href="<?php echo base_url('assets');?>/lib/iCheck/square/blue.css" rel="stylesheet" type="text/css" />

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body class="login-page">
    <div class="login-box">
      <div class="login-logo">
        <h1 class="bounceInDown animated"><b>Anime login</b></h1>
      </div><!-- /.login-logo -->
      <div class="login-box-body">
          <p class="login-box-msg" >Sign in to start your session</p>
        <form action="javascript:void(0)" method="post">
          <div class="form-group has-feedback">
            <input type="test"  id = "userid" name="userid" class="form-control" placeholder="User name"/>
            <span class="glyphicon glyphicon-user form-control-feedback"></span>
          </div>
          <div class="form-group has-feedback">
            <input type="password" id ="password"  class="form-control"   name="password" placeholder="Password"/>
            <span class="glyphicon glyphicon-lock form-control-feedback"></span>
          </div>
          <div class="row">
            <div class="col-xs-8">    
              <div class="checkbox icheck">
                <label>
                  <input type="checkbox"> Remember Me
                </label>
              </div>                        
            </div><!-- /.col -->
            <div class="col-xs-4">
              <button type="submit" class="btn btn-primary btn-block btn-flat ok">Sign In</button>
            </div><!-- /.col -->
          </div>
        </form>
        <a href="#">I forgot my password</a><br>
        <a href="register.html" class="text-center">Register a new membership</a>
      </div><!-- /.login-box-body -->
    </div><!-- /.login-box -->

    <!-- jQuery 2.1.4 -->
    <script src="<?php echo base_url('assets');?>/lib/jQuery/js/jQuery-2.1.4.min.js"></script>
    <!-- Bootstrap 3.3.2 JS -->
    <script src="<?php echo base_url('assets');?>/lib/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <!-- iCheck -->
    <script src="<?php echo base_url('assets');?>/lib/iCheck/icheck.min.js" type="text/javascript"></script>
    <script>
      $(function () {
        $('input').iCheck({
          checkboxClass: 'icheckbox_square-blue',
          radioClass: 'iradio_square-blue',
          increaseArea: '20%' // optional
        });
      });
      $(document).ready(function(e) {
           $('.ok').click(function(){
              var user = $('#userid').val();
              var pass = $('#password').val();
              var type = 'abc'; 
              if(user == ""){
                  $('.login-box-msg').removeClass('alert-info');
                  $('.login-box-msg').addClass('alert-danger');          
                  $('.login-box-msg').html('Please Enter User !');
                  $('#userid').focus();
                  return false;
              }
              if(pass  == ""){
                  $('.login-box-msg').removeClass('alert-info');
                  $('.login-box-msg').addClass('alert-danger');
                  $('.login-box-msg').html('Please Enter password !');
                  $('#password').focus();
                  return false;
              }
              $.ajax({
                  'url' :  '<?php echo base_url() ;?>admin/login',
                  'type' : 'post',
                  'data' : 'type='+type+'&username='+user+'&password='+pass,
                  'async' : 'false',
                  beforeSend : function(){
                      //$("#result_login").html("Đang load dữ liệu...");
                      //<img class='check_suscess' src='"+links+"public/admin/images/load_form.gif' />
                      $('.login-box-msg').removeClass('alert-info')
                      $('.login-box-msg').removeClass('alert')
                      $('.login-box-msg').removeClass('alert-danger')
                      $('.login-box-msg').html('<img src="<?php echo base_url();?>assets/admin/img/Progressbar.gif" width="100" height="50px" />');
                  },
                  success: function(result){
                      if(result === 'false'){
                          $('.login-box-msg').removeClass('alert-info');
                          $('.login-box-msg').addClass('alert-danger');
                          $('.login-box-msg').addClass('alert');
                          $('.login-box-msg').html('Wrong username or password !');
                          return false;
                      }else if(result === 'notactive'){
                          $('.login-box-msg').removeClass('alert-info');
                          $('.login-box-msg').addClass('alert-danger');
                          $('.login-box-msg').addClass('alert');
                          $('.login-box-msg').html('This account is not activated yet! Please check email or contact Administrator. Thanks!');
                          return false;
                      }else if(result == 'notlogin'){
                          $('.login-box-msg').removeClass('alert-info');
                          $('.login-box-msg').addClass('alert-danger');
                          $('.login-box-msg').addClass('alert');
                          $('.login-box-msg').html('Account is logged . Thanks!');
                          return false;
                      }
                      else{
                          var url = '<?php echo base_url("admin/home")?>';
                          window.location.href = url; 
                      }
                  }
              });
              return false;
          });
      });
    </script>
  </body>
</html>